set(ENV_PATH "$ENV{PATH}")
set(ENV_CMAKE_PREFIX_PATH "$ENV{CMAKE_PREFIX_PATH}")
set(ENV{PATH} "")
set(ENV{CMAKE_PREFIX_PATH} "")

list(APPEND CMAKE_FIND_LIBRARY_PREFIXES lib)
list(APPEND CMAKE_FIND_LIBRARY_SUFFIXES .a)

file(MAKE_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/lib)
file(WRITE "${CMAKE_CURRENT_BINARY_DIR}/lib/libcreated.a" "created")

set(CMAKE_FIND_DEBUG_MODE 1)
set(CMAKE_FIND_USE_INSTALL_PREFIX OFF)

find_library(CREATED_LIBRARY NAMES created)
message(STATUS "CREATED_LIBRARY='${CREATED_LIBRARY}'")

set(CMAKE_FIND_USE_INSTALL_PREFIX ON)
find_library(CREATED_LIBRARY NAMES created)
message(STATUS "CREATED_LIBRARY='${CREATED_LIBRARY}'")

unset(CREATED_LIBRARY)
unset(CREATED_LIBRARY CACHE)

unset(CMAKE_FIND_USE_INSTALL_PREFIX)
find_library(CREATED_LIBRARY NAMES created NO_CMAKE_INSTALL_PREFIX)
message(STATUS "CREATED_LIBRARY='${CREATED_LIBRARY}'")

set(CMAKE_FIND_DEBUG_MODE 0)

set(ENV{PATH} "${ENV_PATH}")
set(ENV{CMAKE_PREFIX_PATH} "${ENV_CMAKE_PREFIX_PATH}")
